﻿using System.IO;

namespace TroubleshootingofBeanBagAssistant
{
	public static class DiskSpaceHelper
	{
		/// <summary>
		/// 获取指定驱动器的可用空间（字节）
		/// </summary>
		/// <param name="driveLetter">如 "C:\"</param>
		/// <returns>可用空间（字节），获取失败返回-1</returns>
		public static long GetFreeDiskSpace(string driveLetter)
		{
			try
			{
				var drive = new DriveInfo(driveLetter);
				if (drive.IsReady)
				{
					return drive.AvailableFreeSpace;
				}
			}
			catch
			{
				// 忽略异常，返回-1
			}
			return -1;
		}
	}
}
